import { EntitySchema } from '@mikro-orm/core';

export class LeFinance {
  id!: string;
  UID?: string;
  orderSn!: string;
  price!: string;
  serviceCharge!: string;
  type!: string;
  extra!: unknown;
  status: number = 0;
  remark!: string;
  name!: string;
  model!: string;
  transferStatus: boolean = false;
  mobile!: string;
  AppID!: string;
  merchantId!: string;
  createdTime?: number = 0;
  updatedTime?: number = 0;
  deletedTime?: number = 0;
  isDeleted?: number = 0;
}

export const LeFinanceSchema = new EntitySchema({
  class: LeFinance,
  properties: {
    id: { primary: true, type: 'string', columnType: 'bigint' },
    UID: { type: 'string', fieldName: 'UID', columnType: 'bigint', nullable: true },
    orderSn: { type: 'string', length: 50 },
    price: { type: 'string', columnType: 'numeric(10,2)' },
    serviceCharge: { type: 'string', columnType: 'numeric(10,2)', defaultRaw: `0.00` },
    type: { type: 'string', length: 10 },
    extra: { type: 'unknown', columnType: 'longtext' },
    status: { type: 'number', columnType: 'tinyint', default: 0 },
    remark: { type: 'string', length: 1024 },
    name: { type: 'string', length: 50 },
    model: { type: 'string', length: 50 },
    transferStatus: { type: 'boolean', default: false },
    mobile: { type: 'string', length: 20 },
    AppID: { type: 'string', fieldName: 'AppID', length: 50 },
    merchantId: { type: 'string', columnType: 'bigint' },
    createdTime: { type: 'number', nullable: true, default: 0 },
    updatedTime: { type: 'number', nullable: true, default: 0 },
    deletedTime: { type: 'number', nullable: true, default: 0 },
    isDeleted: { type: 'number', columnType: 'tinyint', nullable: true, default: 0 },
  },
});
